package Animal.com;

public abstract class BankAccount {
    private  String accountNumber;
    private double balance;

    public BankAccount(String accountNumber, double balance) {
        this.accountNumber = accountNumber;
        this.balance = balance;
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public double getBalance() {
        return balance;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public void  withdraw(double num){
    }
    public void depositd(double num){
    }
}
 class SavinsAccount extends BankAccount{

    public SavinsAccount(String accountNumber, double balance) {
        super(accountNumber, balance);
    }

    @Override
    public void withdraw(double num) {
        System.out.println("账户编号：" + getAccountNumber());
        if (getBalance() >= num) {
            setBalance(getBalance() - num);
            System.out.println("成功取出" + num + "，余额为：" + getBalance());
        }else {
            System.out.println("余额不足！");
        }
    }
    @Override
    public void depositd(double num) {
        setBalance(getBalance() + num);
        System.out.println("恭喜你！存入" + num + "，余额为：" + getBalance());
    }
}
class  heckingAccount extends BankAccount{
    private double  overdraftLlinit;
    public heckingAccount(String accountNumber, double balance, double overdraftLlinit) {
        super(accountNumber, balance);
        this.overdraftLlinit = overdraftLlinit;
    }

    public void withdraw(double num) {
        System.out.println("账户编号：" + getAccountNumber());
        if (getBalance() + overdraftLlinit >= num){
            System.out.println("您的透支余额为：" + overdraftLlinit );
            setBalance(getBalance() - num);
            System.out.println("成功取出" + num + "，余额为：" + getBalance());
        }else {
            System.out.println("余额不足！");
        }
    }

    @Override
    public void depositd(double num) {
        setBalance(getBalance() + num);
        System.out.println("恭喜你！存入" + num + "，余额为：" + getBalance());
    }
}

class Test1 {
    public static void main(String[] args) {
        SavinsAccount savinsAccount = new SavinsAccount("00010",5000) ;
        heckingAccount heckingAccount = new heckingAccount("00011",8000,5000);

        System.out.println("*****普通账户*****");
        savinsAccount.withdraw(2000);
        savinsAccount.depositd(7000);

        System.out.println("*****支票账户*****");
        heckingAccount.withdraw(10000);
        heckingAccount.depositd(2000);
    }
}